var wsUrl = "ws://39.105.67.193:8812";
var ws  = new WebSocket(wsUrl);
ws.onopen = function(evt) {
    console.log('connected-swoole-success');
};

ws.onmessage = function(evt) {
    push(evt.data);
    console.log("Received Message: " + evt.data.fd);
};

ws.onclose = function(evt) {
    console.log("Connection closed.");
};
ws.onerror = function(event) {
    console.log('error:'+event.data);
};
function push(data)
{
    data = $.parseJSON(data);
    html = '<div class="comment">';
    html += '<span>'+data.user+'</span>';
    html += ' 说:  ';
    html += '<span>'+data.data+'</span>';
    html += '</div>';

    $('#comments').append(html);
    $('#discuss-box').val('');
}